package com.example.provider.impl;

import com.alibaba.fastjson.JSON;
import com.example.api.Order;
import com.example.api.SexType;
import com.example.api.UserProvider;
import org.springframework.stereotype.Service;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;
import java.util.Map;

/**
 * <b><code>UserProviderImpl</code></b>
 * <p>
 * Description
 * <p>
 * <b>Create Time:</b> 2023/2/17 16:20.
 *
 * @author qd.yt
 * @version 0.0.1
 * @since demo-openfeign v0.0.1
 */
@RestController
@RequestMapping("/user-provider/user")
public class UserProviderImpl implements UserProvider {
    @Override
    public String getUser(@RequestParam("id") Integer id) {
        return "List"+id;
    }

    @Override
    public String getUser(Integer id, String name) {
        return "id:"+id+",name:"+name;
    }

    @Override
    public String getUser2(Integer id, String name, String age) {
         return "id:"+id+",name:"+name+",age:"+age;
    }

    @Override
    public String saveOrder(Order order) {
        return JSON.toJSONString(order);
    }

    @Override
    public String updateOrder(Order order, String id) {
        String abc = JSON.toJSONString(order);
        return "更新:"+id+",数据:"+abc;
    }

    @Override
    public String sendMap(Map<String, Object> commandPack) {
        return JSON.toJSONString(commandPack);
    }

    @Override
    public String sendList(String id, List<Order> orders) {
        String abc = JSON.toJSONString(orders);
        return "更新List:"+id+",数据:"+abc;
    }

    @Override
    public String sendListMore(String id, String uid, List<Order> orders, Order order) {
        String abc = JSON.toJSONString(orders);
        return "更新ListMore:id"+id+",uid"+uid+",orders:"+abc+",order:"+JSON.toJSONString(order);
    }

    @Override
    public String sendListMap(Map<String, Object> commandPack, List<Order> orders) {
        return "更新sendListMap:map"+JSON.toJSONString(commandPack)+",order:"+JSON.toJSONString(orders);
    }

    @Override
    public String sendEnumList(SexType sexType, String id, List<String> idsList) {
        return "sexType:"+sexType.getDescription()+",id:"+id+",idsList:"+JSON.toJSONString(idsList);
    }
}
